#!/bin/bash
#This is a sub-treasury backup script for MySQL.
#
# File save time is 7 days.

bapath="/data/DBbackup/DBfile/"
if [ ! -d $bapath ];then
  mkdir -p $bapath
fi
filename=`date +%Y-%m-%d`'.sql'
#databases=(acs activemq appdatamonitor authorize autosettle basis cashier cert cmf counter csa deposit dpm ffs fos guardian jdedb lflt member mns oss payment pbs pfs pns rms smsgateway ssop tradereports tss ues voucher wallet)


for db in information_schema ddepps mysql performance_schema sys 
do 
/usr/bin/mysqldump -uroot -p'xxxx!xxxxx#7' --opt --default-character-set=utf8 --triggers --hex-blob --skip-lock-tables $db >$bapath$db-$filename
cd $bapath
tar zcf $bapath$db-$filename.tar.gz $db-$filename
find $bapath -mtime +7 -name "*.sql.tar.gz" -exec rm -rf {} \;
done
rm -rf ${bapath}*.sql

